home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6303 < prev    next >
Mailbox/MIME Entity  |  1996-08-05  |  7.9 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: Mailbox/MIME Entity (archive/mbox).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Newsgroup Content (archive/news) magic Supported
100% dexvert Mailbox/MIME Entity (archive/mbox) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file news text default
99% file C source text default
98% file C source, ASCII text default
100% checkBytes Printable ASCII default
100% dexmagic PrintFox/Pagefox WEAK default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/950 MIME Email (1.0) default
100% detectItEasy Format: plain text[LF] default (weak)
100% xdgMime message/news default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 50 61 74 68 3a 20 64 69 | 6c 64 6f 67 2e 6c 67 63 |Path: di|ldog.lgc|
|00000010| 2e 63 6f 6d 21 75 73 65 | 6e 65 74 0a 46 72 6f 6d |.com!use|net.From|
|00000020| 3a 20 47 6c 65 6e 6e 20 | 43 61 72 72 20 3c 67 63 |: Glenn |Carr <gc|
|00000030| 61 72 72 40 74 75 6c 73 | 61 2e 6c 67 63 2e 63 6f |arr@tuls|a.lgc.co|
|00000040| 6d 3e 0a 4e 65 77 73 67 | 72 6f 75 70 73 3a 20 63 |m>.Newsg|roups: c|
|00000050| 6f 6d 70 2e 6c 61 6e 67 | 2e 63 0a 53 75 62 6a 65 |omp.lang|.c.Subje|
|00000060| 63 74 3a 20 52 65 3a 20 | 50 72 65 2d 70 72 6f 63 |ct: Re: |Pre-proc|
|00000070| 65 73 73 69 6e 67 3a 20 | 20 43 61 6e 20 74 68 69 |essing: | Can thi|
|00000080| 73 20 62 65 20 64 6f 6e | 65 3f 0a 44 61 74 65 3a |s be don|e?.Date:|
|00000090| 20 46 72 69 2c 20 32 33 | 20 46 65 62 20 31 39 39 | Fri, 23| Feb 199|
|000000a0| 36 20 31 34 3a 34 31 3a | 33 37 20 2d 30 36 30 30 |6 14:41:|37 -0600|
|000000b0| 0a 4f 72 67 61 6e 69 7a | 61 74 69 6f 6e 3a 20 4c |.Organiz|ation: L|
|000000c0| 61 6e 64 6d 61 72 6b 20 | 47 72 61 70 68 69 63 73 |andmark |Graphics|
|000000d0| 0a 4d 65 73 73 61 67 65 | 2d 49 44 3a 20 3c 33 31 |.Message|-ID: <31|
|000000e0| 32 45 32 36 38 31 2e 31 | 36 37 45 42 30 45 37 40 |2E2681.1|67EB0E7@|
|000000f0| 74 75 6c 73 61 2e 6c 67 | 63 2e 63 6f 6d 3e 0a 52 |tulsa.lg|c.com>.R|
|00000100| 65 66 65 72 65 6e 63 65 | 73 3a 20 3c 44 4d 47 6f |eference|s: <DMGo|
|00000110| 34 74 2e 37 72 37 40 67 | 74 69 2d 69 61 2e 6e 6c |4t.7r7@g|ti-ia.nl|
|00000120| 3e 0a 4e 4e 54 50 2d 50 | 6f 73 74 69 6e 67 2d 48 |>.NNTP-P|osting-H|
|00000130| 6f 73 74 3a 20 61 72 69 | 73 2e 74 75 6c 73 61 2e |ost: ari|s.tulsa.|
|00000140| 6c 67 63 2e 63 6f 6d 0a | 4d 69 6d 65 2d 56 65 72 |lgc.com.|Mime-Ver|
|00000150| 73 69 6f 6e 3a 20 31 2e | 30 0a 43 6f 6e 74 65 6e |sion: 1.|0.Conten|
|00000160| 74 2d 54 79 70 65 3a 20 | 74 65 78 74 2f 70 6c 61 |t-Type: |text/pla|
|00000170| 69 6e 3b 20 63 68 61 72 | 73 65 74 3d 75 73 2d 61 |in; char|set=us-a|
|00000180| 73 63 69 69 0a 43 6f 6e | 74 65 6e 74 2d 54 72 61 |scii.Con|tent-Tra|
|00000190| 6e 73 66 65 72 2d 45 6e | 63 6f 64 69 6e 67 3a 20 |nsfer-En|coding: |
|000001a0| 37 62 69 74 0a 58 2d 4d | 61 69 6c 65 72 3a 20 4d |7bit.X-M|ailer: M|
|000001b0| 6f 7a 69 6c 6c 61 20 32 | 2e 30 20 28 58 31 31 3b |ozilla 2|.0 (X11;|
|000001c0| 20 49 3b 20 53 75 6e 4f | 53 20 34 2e 31 42 20 73 | I; SunO|S 4.1B s|
|000001d0| 75 6e 34 29 0a 54 6f 3a | 20 70 61 75 6c 77 40 67 |un4).To:| paulw@g|
|000001e0| 74 69 2d 69 61 2e 6e 6c | 0a 0a 50 61 75 6c 20 57 |ti-ia.nl|..Paul W|
|000001f0| 61 6c 6c 69 73 20 77 72 | 6f 74 65 3a 0a 3e 20 0a |allis wr|ote:.> .|
|00000200| 3e 20 48 69 20 61 6c 6c | 2c 0a 3e 20 0a 3e 20 49 |> Hi all|,.> .> I|
|00000210| 27 6d 20 74 72 79 69 6e | 67 20 74 6f 20 77 72 69 |'m tryin|g to wri|
|00000220| 74 65 20 61 20 66 75 6e | 63 74 69 6f 6e 20 77 68 |te a fun|ction wh|
|00000230| 69 63 68 20 77 69 6c 6c | 20 70 72 69 6e 74 20 74 |ich will| print t|
|00000240| 72 61 63 65 20 73 74 61 | 74 65 6d 65 6e 74 73 2e |race sta|tements.|
|00000250| 0a 3e 20 49 20 77 61 6e | 74 20 74 68 65 20 66 69 |.> I wan|t the fi|
|00000260| 6c 65 20 61 6e 64 20 6c | 69 6e 65 20 74 6f 20 62 |le and l|ine to b|
|00000270| 65 20 61 64 64 65 64 20 | 74 6f 20 74 68 65 20 61 |e added |to the a|
|00000280| 72 67 75 6d 65 6e 74 20 | 6c 69 73 74 0a 3e 20 61 |rgument |list.> a|
|00000290| 75 74 6f 6d 61 74 69 63 | 61 6c 6c 79 2e 20 20 49 |utomatic|ally. I|
|000002a0| 20 61 6d 2c 20 68 6f 77 | 65 76 65 72 2c 20 68 61 | am, how|ever, ha|
|000002b0| 76 69 6e 67 20 73 6f 6d | 65 20 70 72 6f 62 6c 65 |ving som|e proble|
|000002c0| 6d 73 20 77 6f 72 6b 69 | 6e 67 0a 3e 20 6d 79 20 |ms worki|ng.> my |
|000002d0| 77 61 79 20 61 72 6f 75 | 6e 64 20 74 68 65 20 70 |way arou|nd the p|
|000002e0| 72 65 2d 70 72 6f 63 65 | 73 73 6f 72 2e 20 49 20 |re-proce|ssor. I |
|000002f0| 77 6f 75 6c 64 20 6c 69 | 6b 65 20 74 6f 20 62 65 |would li|ke to be|
|00000300| 20 61 62 6c 65 20 74 6f | 20 65 6e 74 65 72 0a 3e | able to| enter.>|
|00000310| 20 74 68 65 20 66 6f 6c | 6c 6f 77 69 6e 67 20 6c | the fol|lowing l|
|00000320| 69 6e 65 3a 0a 3e 20 0a | 3e 20 20 20 20 20 20 20 |ine:.> .|> |
|00000330| 20 20 74 72 61 63 65 28 | 22 25 64 2c 20 25 66 22 | trace(|"%d, %f"|
|00000340| 2c 20 61 6e 5f 69 6e 74 | 2c 20 61 5f 66 6c 6f 61 |, an_int|, a_floa|
|00000350| 74 29 3b 0a 3e 20 0a 3e | 20 61 6e 64 20 68 61 76 |t);.> .>| and hav|
|00000360| 65 20 74 68 65 20 61 72 | 67 75 6d 65 6e 74 73 20 |e the ar|guments |
|00000370| 70 61 73 73 65 64 20 61 | 73 20 73 6f 3a 0a 3e 20 |passed a|s so:.> |
|00000380| 0a 3e 20 20 20 20 20 20 | 20 20 20 5f 74 72 61 63 |.> | _trac|
|00000390| 65 28 5f 5f 46 49 4c 45 | 5f 5f 2c 20 5f 5f 4c 49 |e(__FILE|__, __LI|
|000003a0| 4e 45 5f 5f 2c 20 22 25 | 64 2c 20 25 66 22 2c 20 |NE__, "%|d, %f", |
|000003b0| 61 6e 5f 69 6e 74 2c 20 | 61 5f 66 6c 6f 61 74 29 |an_int, |a_float)|
|000003c0| 3b 0a 3e 20 0a 3e 20 49 | 20 68 61 76 65 20 64 65 |;.> .> I| have de|
|000003d0| 66 69 6e 65 64 20 61 20 | 6d 61 63 72 6f 20 74 72 |fined a |macro tr|
|000003e0| 61 63 65 20 73 6f 3a 0a | 3e 20 0a 3e 20 20 20 20 |ace so:.|> .> |
|000003f0| 20 20 20 20 20 23 64 65 | 66 69 6e 65 20 74 72 61 | #de|fine tra|
|00000400| 63 65 28 78 29 20 5f 74 | 72 61 63 65 28 5f 5f 46 |ce(x) _t|race(__F|
|00000410| 49 4c 45 5f 5f 2c 20 5f | 5f 4c 49 4e 45 5f 5f 2c |ILE__, _|_LINE__,|
|00000420| 20 78 29 0a 3e 20 0a 3e | 20 4e 6f 77 20 77 68 61 | x).> .>| Now wha|
|00000430| 74 20 49 27 76 65 20 66 | 6f 75 6e 64 20 69 73 20 |t I've f|ound is |
|00000440| 74 68 61 74 20 74 68 65 | 20 70 72 65 2d 70 72 6f |that the| pre-pro|
|00000450| 63 65 73 73 6f 72 20 27 | 74 68 72 6f 77 73 20 61 |cessor '|throws a|
|00000460| 20 77 6f 62 62 6c 65 72 | 27 0a 3e 20 61 74 20 74 | wobbler|'.> at t|
|00000470| 68 65 20 78 2e 20 20 41 | 70 70 61 72 65 6e 74 6c |he x. A|pparentl|
|00000480| 79 20 6e 6f 74 20 6c 69 | 6b 69 6e 67 20 6d 75 6c |y not li|king mul|
|00000490| 74 69 70 6c 65 20 61 72 | 67 75 6d 65 6e 74 73 2e |tiple ar|guments.|
|000004a0| 20 20 49 73 20 74 68 65 | 72 65 0a 3e 20 61 6e 79 | Is the|re.> any|
|000004b0| 20 77 61 79 20 74 6f 20 | 67 65 74 20 69 74 20 74 | way to |get it t|
|000004c0| 6f 20 61 63 63 65 70 74 | 20 74 68 69 73 2c 20 77 |o accept| this, w|
|000004d0| 69 74 68 6f 75 74 20 68 | 61 76 69 6e 67 20 74 6f |ithout h|aving to|
|000004e0| 20 64 6f 20 74 68 69 73 | 2c 0a 3e 20 77 68 69 63 | do this|,.> whic|
|000004f0| 68 20 69 73 20 76 65 72 | 79 20 75 67 6c 79 3a 0a |h is ver|y ugly:.|
|00000500| 3e 20 0a 3e 20 20 20 20 | 20 20 20 20 20 74 72 61 |> .> | tra|
|00000510| 63 65 28 28 22 25 64 2c | 20 25 66 22 2c 20 61 6e |ce(("%d,| %f", an|
|00000520| 5f 69 6e 74 2c 20 61 5f | 66 6c 6f 61 74 29 29 3b |_int, a_|float));|
|00000530| 0a 3e 20 0a 3e 20 49 20 | 68 61 76 65 20 61 6c 73 |.> .> I |have als|
|00000540| 6f 20 74 72 69 65 64 20 | 72 65 64 65 66 69 6e 69 |o tried |redefini|
|00000550| 6e 67 20 61 20 6d 61 63 | 72 6f 20 61 73 20 73 75 |ng a mac|ro as su|
|00000560| 63 68 3a 0a 3e 20 0a 3e | 20 20 20 20 20 20 20 20 |ch:.> .>| |
|00000570| 20 23 64 65 66 69 6e 65 | 20 74 72 61 63 65 28 20 | #define| trace( |
|00000580| 5f 74 72 61 63 65 28 5f | 5f 46 49 4c 45 5f 5f 2c |_trace(_|_FILE__,|
|00000590| 20 5f 5f 4c 49 4e 45 5f | 5f 0a 3e 20 0a 3e 20 62 | __LINE_|_.> .> b|
|000005a0| 75 74 20 74 6f 20 6e 6f | 20 61 76 61 69 6c 2e 20 |ut to no| avail. |
|000005b0| 20 49 73 20 74 68 65 72 | 65 20 61 6e 20 61 6e 73 | Is ther|e an ans|
|000005c0| 77 65 72 2c 20 6f 72 20 | 61 6d 20 49 20 73 74 75 |wer, or |am I stu|
|000005d0| 63 6b 20 77 69 74 68 20 | 74 68 65 0a 3e 20 75 67 |ck with |the.> ug|
|000005e0| 6c 79 3f 0a 3e 20 0a 0a | 48 65 72 65 27 73 20 74 |ly?.> ..|Here's t|
|000005f0| 68 65 20 68 65 61 64 65 | 72 20 61 6e 64 20 73 6f |he heade|r and so|
|00000600| 75 72 63 65 20 74 6f 20 | 74 68 65 20 74 72 61 63 |urce to |the trac|
|00000610| 65 20 72 6f 75 74 69 6e | 67 20 49 20 75 73 65 20 |e routin|g I use |
|00000620| 74 6f 0a 64 6f 20 65 78 | 61 63 74 6c 79 20 74 68 |to.do ex|actly th|
|00000630| 61 74 2c 20 70 6c 75 73 | 20 6f 70 74 69 6f 6e 61 |at, plus| optiona|
|00000640| 6c 6c 79 20 61 64 64 20 | 61 20 74 69 6d 65 73 74 |lly add |a timest|
|00000650| 61 6d 70 20 74 6f 20 65 | 61 63 68 20 6c 69 6e 65 |amp to e|ach line|
|00000660| 2e 0a 0a 28 49 20 6f 77 | 65 20 74 68 69 73 20 74 |...(I ow|e this t|
|00000670| 6f 20 4d 69 63 68 61 65 | 6c 20 44 61 76 69 64 73 |o Michae|l Davids|
|00000680| 6f 6e 20 77 68 6f 20 70 | 6f 73 74 65 64 20 61 20 |on who p|osted a |
|00000690| 73 69 6d 70 6c 65 72 20 | 76 65 72 73 69 6f 6e 20 |simpler |version |
|000006a0| 0a 6f 66 20 74 68 69 73 | 20 77 68 69 6c 65 20 61 |.of this| while a|
|000006b0| 67 6f 2e 20 20 49 20 69 | 6e 63 6c 75 64 65 64 20 |go. I i|ncluded |
|000006c0| 68 69 73 20 70 6f 73 74 | 20 61 74 20 74 68 65 20 |his post| at the |
|000006d0| 65 6e 64 20 77 68 69 63 | 68 0a 68 61 73 20 61 6e |end whic|h.has an|
|000006e0| 6f 74 68 65 72 20 27 74 | 72 69 63 6b 69 65 72 27 |other 't|rickier'|
|000006f0| 20 74 65 63 68 6e 69 71 | 75 65 2e 29 0a 0a 49 20 | techniq|ue.)..I |
|00000700| 75 73 65 20 69 74 20 62 | 79 20 69 6e 63 6c 75 64 |use it b|y includ|
|00000710| 69 6e 67 20 74 68 65 20 | 68 65 61 64 65 72 20 28 |ing the |header (|
|00000720| 64 62 67 75 74 69 6c 2e | 68 29 20 69 6e 20 74 68 |dbgutil.|h) in th|
|00000730| 65 20 73 6f 75 72 63 65 | 0a 61 6e 64 20 74 68 65 |e source|.and the|
|00000740| 6e 20 6d 79 20 74 72 61 | 63 65 20 73 74 75 66 66 |n my tra|ce stuff|
|00000750| 20 6c 6f 6f 6b 73 20 6c | 69 6b 65 20 74 68 69 73 | looks l|ike this|
|00000760| 2e 2e 2e 0a 0a 44 62 67 | 28 22 6e 6f 72 6d 61 6c |.....Dbg|("normal|
|00000770| 20 70 72 69 6e 74 66 20 | 73 74 75 66 66 2c 20 25 | printf |stuff, %|
|00000780| 73 2c 20 25 64 2c 20 25 | 64 5c 6e 22 2c 20 22 74 |s, %d, %|d\n", "t|
|00000790| 65 73 74 69 6e 67 22 2c | 31 2c 32 29 3b 0a 0a 2e |esting",|1,2);...|
|000007a0| 2e 2e 61 6e 64 20 69 74 | 20 73 70 69 74 73 20 6f |..and it| spits o|
|000007b0| 75 74 20 73 6f 6d 65 74 | 68 69 6e 67 20 6c 69 6b |ut somet|hing lik|
|000007c0| 65 2e 2e 2e 0a 0a 5b 30 | 32 2f 32 33 20 31 33 3a |e.....[0|2/23 13:|
|000007d0| 30 39 3a 35 32 20 6d 61 | 69 6e 2e 63 2c 35 30 31 |09:52 ma|in.c,501|
|000007e0| 5d 20 6e 6f 72 6d 61 6c | 20 70 72 69 6e 74 66 20 |] normal| printf |
|000007f0| 73 74 75 66 66 2c 20 74 | 65 73 74 69 6e 67 2c 20 |stuff, t|esting, |
|00000800| 31 2c 20 32 0a 0a 49 20 | 6c 69 6b 65 20 69 74 20 |1, 2..I |like it |
|00000810| 62 65 63 61 75 73 65 20 | 49 20 75 6e 64 65 66 69 |because |I undefi|
|00000820| 6e 65 20 44 45 42 55 47 | 20 74 6f 20 74 61 6b 65 |ne DEBUG| to take|
|00000830| 20 6f 75 74 20 74 68 65 | 0a 74 72 61 63 69 6e 67 | out the|.tracing|
|00000840| 20 6f 72 20 49 20 63 61 | 6e 20 74 75 72 6e 20 69 | or I ca|n turn i|
|00000850| 74 20 6f 6e 2f 6f 66 66 | 20 61 74 20 72 75 6e 74 |t on/off| at runt|
|00000860| 69 6d 65 20 62 79 20 63 | 61 6c 6c 69 6e 67 2e 2e |ime by c|alling..|
|00000870| 2e 0a 0a 09 44 62 67 4c | 6f 67 53 65 74 28 4f 6e |....DbgL|ogSet(On|
|00000880| 4f 72 4f 66 66 29 0a 0a | 2e 2e 2e 69 66 20 44 45 |OrOff)..|...if DE|
|00000890| 42 55 47 20 69 73 20 64 | 65 66 69 6e 65 64 2e 0a |BUG is d|efined..|
|000008a0| 0a 0a 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |..------|--------|
|000008b0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|000008c0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|000008d0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 0a 64 62 67 75 |--------|---.dbgu|
|000008e0| 74 69 6c 2e 68 3a 0a 0a | 2f 2a 0a 20 2a 20 55 73 |til.h:..|/*. * Us|
|000008f0| 61 67 65 3a 20 44 62 67 | 4c 6f 67 28 20 22 6e 6f |age: Dbg|Log( "no|
|00000900| 72 6d 61 6c 20 70 72 69 | 6e 74 66 20 73 74 75 66 |rmal pri|ntf stuf|
|00000910| 66 2e 2e 2e 25 64 2c 25 | 73 2c 65 74 63 5c 6e 22 |f...%d,%|s,etc\n"|
|00000920| 2c 20 31 2c 20 22 74 77 | 6f 22 20 29 3b 0a 20 2a |, 1, "tw|o" );. *|
|00000930| 0a 20 2a 20 4f 70 74 69 | 6f 6e 61 6c 6c 79 2c 20 |. * Opti|onally, |
|00000940| 74 68 65 20 6d 61 63 72 | 6f 20 44 42 47 4c 4f 47 |the macr|o DBGLOG|
|00000950| 5f 54 49 4d 45 46 4d 54 | 20 63 61 6e 20 62 65 20 |_TIMEFMT| can be |
|00000960| 72 65 64 65 66 69 6e 65 | 64 20 62 65 66 6f 72 65 |redefine|d before|
|00000970| 20 6f 72 0a 20 2a 20 61 | 66 74 65 72 20 69 6e 63 | or. * a|fter inc|
|00000980| 6c 75 64 69 6e 67 20 74 | 68 69 73 20 68 65 61 64 |luding t|his head|
|00000990| 65 72 20 66 69 6c 65 20 | 74 6f 20 61 20 76 61 6c |er file |to a val|
|000009a0| 69 64 20 73 74 72 66 74 | 69 6d 65 20 66 6d 74 20 |id strft|ime fmt |
|000009b0| 73 74 72 69 6e 67 0a 20 | 2a 20 75 73 69 6e 67 20 |string. |* using |
|000009c0| 73 74 72 66 74 69 6d 65 | 20 64 69 72 65 63 74 69 |strftime| directi|
|000009d0| 76 65 73 2e 20 20 46 6f | 72 20 65 78 61 6d 70 6c |ves. Fo|r exampl|
|000009e0| 65 2c 20 54 6f 20 70 75 | 74 20 74 68 65 20 64 61 |e, To pu|t the da|
|000009f0| 79 20 6f 66 20 74 68 65 | 0a 20 2a 20 77 65 65 6b |y of the|. * week|
|00000a00| 2c 20 74 68 65 20 68 6f | 75 72 2c 20 6d 69 6e 75 |, the ho|ur, minu|
|00000a10| 74 65 2c 20 61 6e 64 20 | 73 65 63 6f 6e 64 20 69 |te, and |second i|
|00000a20| 6e 20 74 68 65 20 6f 75 | 74 70 75 74 2e 2e 2e 0a |n the ou|tput....|
|00000a30| 20 2a 0a 20 2a 20 23 69 | 66 64 65 66 20 44 42 47 | *. * #i|fdef DBG|
|00000a40| 4c 4f 47 5f 54 49 4d 45 | 46 4d 54 0a 20 2a 20 23 |LOG_TIME|FMT. * #|
|00000a50| 75 6e 64 65 66 20 44 42 | 47 4c 4f 47 5f 54 49 4d |undef DB|GLOG_TIM|
|00000a60| 45 46 4d 54 0a 20 2a 20 | 23 65 6e 64 69 66 0a 20 |EFMT. * |#endif. |
|00000a70| 2a 20 23 64 65 66 69 6e | 65 20 44 42 47 4c 4f 47 |* #defin|e DBGLOG|
|00000a80| 5f 54 49 4d 45 46 4d 54 | 20 22 25 41 2c 20 25 48 |_TIMEFMT| "%A, %H|
|00000a90| 3a 25 4d 3a 25 53 22 0a | 20 2a 0a 20 2a 20 54 6f |:%M:%S".| *. * To|
|00000aa0| 20 70 75 74 20 67 65 74 | 20 72 69 64 20 6f 66 20 | put get| rid of |
|00000ab0| 74 68 65 20 74 69 6d 65 | 73 74 61 6d 70 20 65 6e |the time|stamp en|
|00000ac0| 74 69 72 65 6c 79 2e 2e | 2e 0a 20 2a 0a 20 2a 20 |tirely..|.. *. * |
|00000ad0| 23 69 66 64 65 66 20 44 | 42 47 4c 4f 47 5f 54 49 |#ifdef D|BGLOG_TI|
|00000ae0| 4d 45 46 4d 54 0a 20 2a | 20 23 75 6e 64 65 66 20 |MEFMT. *| #undef |
|00000af0| 44 42 47 4c 4f 47 5f 54 | 49 4d 45 46 4d 54 0a 20 |DBGLOG_T|IMEFMT. |
|00000b00| 2a 20 23 65 6e 64 69 66 | 0a 20 2a 20 23 64 65 66 |* #endif|. * #def|
|00000b10| 69 6e 65 20 44 42 47 4c | 4f 47 5f 54 49 4d 45 46 |ine DBGL|OG_TIMEF|
|00000b20| 4d 54 20 22 22 0a 20 2a | 0a 20 2a 20 53 65 74 20 |MT "". *|. * Set |
|00000b30| 74 68 65 20 65 78 74 65 | 72 6e 61 6c 20 62 6f 6f |the exte|rnal boo|
|00000b40| 6c 65 61 6e 2c 20 67 62 | 44 62 67 4c 6f 67 46 6c |lean, gb|DbgLogFl|
|00000b50| 61 67 2c 20 74 72 75 65 | 20 6f 72 20 66 61 6c 73 |ag, true| or fals|
|00000b60| 65 20 74 6f 20 74 75 72 | 6e 20 6f 6e 0a 20 2a 20 |e to tur|n on. * |
|00000b70| 6f 72 20 74 75 72 6e 20 | 6f 66 66 20 64 65 62 75 |or turn |off debu|
|00000b80| 67 67 69 6e 67 20 77 69 | 74 68 6f 75 74 20 72 65 |gging wi|thout re|
|00000b90| 63 6f 6d 70 69 6c 69 6e | 67 2e 0a 20 2a 0a 20 2a |compilin|g.. *. *|
|00000ba0| 20 54 68 65 20 64 65 66 | 61 75 6c 74 20 64 65 66 | The def|ault def|
|00000bb0| 69 6e 69 74 69 6f 6e 20 | 6f 66 20 44 42 47 4c 4f |inition |of DBGLO|
|00000bc0| 47 5f 54 49 4d 45 46 4d | 54 20 69 73 20 64 65 66 |G_TIMEFM|T is def|
|00000bd0| 69 6e 65 64 20 62 65 6c | 6f 77 2e 2e 2e 0a 20 2a |ined bel|ow.... *|
|00000be0| 2f 0a 23 69 66 6e 64 65 | 66 20 5f 44 42 47 55 54 |/.#ifnde|f _DBGUT|
|00000bf0| 49 4c 5f 48 0a 23 64 65 | 66 69 6e 65 20 5f 44 42 |IL_H.#de|fine _DB|
|00000c00| 47 55 54 49 4c 5f 48 0a | 0a 23 69 6e 63 6c 75 64 |GUTIL_H.|.#includ|
|00000c10| 65 20 3c 73 74 64 69 6f | 2e 68 3e 0a 23 69 6e 63 |e <stdio|.h>.#inc|
|00000c20| 6c 75 64 65 20 3c 73 74 | 64 61 72 67 2e 68 3e 0a |lude <st|darg.h>.|
|00000c30| 0a 76 6f 69 64 20 20 20 | 20 20 20 20 20 20 20 20 |.void | |
|00000c40| 20 5f 44 62 67 4c 6f 67 | 53 65 74 28 75 6e 73 69 | _DbgLog|Set(unsi|
|00000c50| 67 6e 65 64 20 63 68 61 | 72 20 62 4f 6e 29 3b 0a |gned cha|r bOn);.|
|00000c60| 76 6f 69 64 20 20 20 20 | 20 20 20 20 20 20 20 20 |void | |
|00000c70| 5f 44 62 67 4c 6f 67 31 | 28 63 68 61 72 20 2a 70 |_DbgLog1|(char *p|
|00000c80| 73 7a 46 69 6c 65 2c 20 | 69 6e 74 20 6e 4c 69 6e |szFile, |int nLin|
|00000c90| 65 2c 20 63 68 61 72 20 | 2a 70 73 7a 54 69 6d 65 |e, char |*pszTime|
|00000ca0| 46 6d 74 29 3b 0a 76 6f | 69 64 20 20 20 20 20 20 |Fmt);.vo|id |
|00000cb0| 20 20 20 20 20 20 5f 44 | 62 67 4c 6f 67 32 28 63 | _D|bgLog2(c|
|00000cc0| 68 61 72 20 2a 70 73 7a | 46 6d 74 2c 2e 2e 2e 29 |har *psz|Fmt,...)|
|00000cd0| 3b 0a 0a 23 69 66 64 65 | 66 20 44 45 42 55 47 0a |;..#ifde|f DEBUG.|
|00000ce0| 0a 23 69 66 6e 64 65 66 | 20 44 42 47 5f 54 49 4d |.#ifndef| DBG_TIM|
|00000cf0| 45 46 4d 54 0a 23 64 65 | 66 69 6e 65 20 44 42 47 |EFMT.#de|fine DBG|
|00000d00| 4c 4f 47 5f 54 49 4d 45 | 46 4d 54 20 22 25 6d 2f |LOG_TIME|FMT "%m/|
|00000d10| 25 64 20 25 48 3a 25 4d | 3a 25 53 22 0a 23 65 6e |%d %H:%M|:%S".#en|
|00000d20| 64 69 66 0a 0a 23 64 65 | 66 69 6e 65 20 44 62 67 |dif..#de|fine Dbg|
|00000d30| 4c 6f 67 20 5f 44 62 67 | 4c 6f 67 31 28 5f 5f 46 |Log _Dbg|Log1(__F|
|00000d40| 49 4c 45 5f 5f 2c 20 5f | 5f 4c 49 4e 45 5f 5f 2c |ILE__, _|_LINE__,|
|00000d50| 20 44 42 47 4c 4f 47 5f | 54 49 4d 45 46 4d 54 29 | DBGLOG_|TIMEFMT)|
|00000d60| 2c 20 5f 44 62 67 4c 6f | 67 32 0a 23 64 65 66 69 |, _DbgLo|g2.#defi|
|00000d70| 6e 65 20 44 62 67 20 20 | 20 20 5f 44 62 67 4c 6f |ne Dbg | _DbgLo|
|00000d80| 67 31 28 5f 5f 46 49 4c | 45 5f 5f 2c 20 5f 5f 4c |g1(__FIL|E__, __L|
|00000d90| 49 4e 45 5f 5f 2c 20 44 | 42 47 4c 4f 47 5f 54 49 |INE__, D|BGLOG_TI|
|00000da0| 4d 45 46 4d 54 29 2c 20 | 5f 44 62 67 4c 6f 67 32 |MEFMT), |_DbgLog2|
|00000db0| 0a 23 64 65 66 69 6e 65 | 20 44 62 67 4c 6f 67 53 |.#define| DbgLogS|
|00000dc0| 65 74 28 66 6c 61 67 29 | 20 5f 44 62 67 4c 6f 67 |et(flag)| _DbgLog|
|00000dd0| 53 65 74 28 66 6c 61 67 | 29 0a 0a 23 69 66 6e 64 |Set(flag|)..#ifnd|
|00000de0| 65 66 20 5f 44 42 47 5f | 53 54 4f 52 41 47 45 0a |ef _DBG_|STORAGE.|
|00000df0| 65 78 74 65 72 6e 0a 23 | 65 6e 64 69 66 0a 75 6e |extern.#|endif.un|
|00000e00| 73 69 67 6e 65 64 20 63 | 68 61 72 20 20 20 67 62 |signed c|har gb|
|00000e10| 44 62 67 4c 6f 67 46 6c | 61 67 0a 23 69 66 64 65 |DbgLogFl|ag.#ifde|
|00000e20| 66 20 5f 44 42 47 5f 53 | 54 4f 52 41 47 45 0a 3d |f _DBG_S|TORAGE.=|
|00000e30| 20 54 52 55 45 0a 23 65 | 6e 64 69 66 0a 20 20 20 | TRUE.#e|ndif. |
|00000e40| 20 20 20 20 20 20 20 20 | 20 20 20 20 3b 0a 23 65 | | ;.#e|
|00000e50| 6c 73 65 0a 23 64 65 66 | 69 6e 65 20 44 62 67 4c |lse.#def|ine DbgL|
|00000e60| 6f 67 20 28 76 6f 69 64 | 29 0a 23 64 65 66 69 6e |og (void|).#defin|
|00000e70| 65 20 44 62 67 20 20 20 | 20 28 76 6f 69 64 29 0a |e Dbg | (void).|
|00000e80| 23 64 65 66 69 6e 65 20 | 44 62 67 4c 6f 67 53 65 |#define |DbgLogSe|
|00000e90| 74 20 28 76 6f 69 64 29 | 0a 23 65 6e 64 69 66 0a |t (void)|.#endif.|
|00000ea0| 0a 23 65 6e 64 69 66 20 | 20 20 20 20 20 20 20 20 |.#endif | |
|00000eb0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000ec0| 20 2f 2a 20 44 42 47 55 | 54 49 4c 5f 48 20 2a 2f | /* DBGU|TIL_H */|
|00000ed0| 0a 0a 0a 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |...-----|--------|
|00000ee0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00000ef0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00000f00| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 0a 64 62 67 |--------|----.dbg|
|00000f10| 75 74 69 6c 2e 63 3a 0a | 0a 23 69 6e 63 6c 75 64 |util.c:.|.#includ|
|00000f20| 65 20 3c 73 74 64 61 72 | 67 2e 68 3e 0a 23 69 6e |e <stdar|g.h>.#in|
|00000f30| 63 6c 75 64 65 20 3c 73 | 74 64 69 6f 2e 68 3e 0a |clude <s|tdio.h>.|
|00000f40| 23 69 6e 63 6c 75 64 65 | 20 3c 73 74 72 69 6e 67 |#include| <string|
|00000f50| 2e 68 3e 0a 23 69 6e 63 | 6c 75 64 65 20 3c 74 69 |.h>.#inc|lude <ti|
|00000f60| 6d 65 2e 68 3e 0a 0a 23 | 64 65 66 69 6e 65 20 44 |me.h>..#|define D|
|00000f70| 45 42 55 47 0a 23 64 65 | 66 69 6e 65 20 5f 44 42 |EBUG.#de|fine _DB|
|00000f80| 47 5f 53 54 4f 52 41 47 | 45 0a 23 69 6e 63 6c 75 |G_STORAG|E.#inclu|
|00000f90| 64 65 20 3c 64 62 67 75 | 74 69 6c 2e 68 3e 20 20 |de <dbgu|til.h> |
|00000fa0| 20 20 20 20 20 20 2f 2a | 20 70 72 6f 74 6f 74 79 | /*| prototy|
|00000fb0| 70 65 73 20 2a 2f 0a 23 | 75 6e 64 65 66 20 20 5f |pes */.#|undef _|
|00000fc0| 44 42 47 5f 53 54 4f 52 | 41 47 45 0a 0a 2f 2a 0a |DBG_STOR|AGE../*.|
|00000fd0| 20 2a 20 55 73 61 67 65 | 3a 20 44 62 67 4c 6f 67 | * Usage|: DbgLog|
|00000fe0| 28 20 22 6e 6f 72 6d 61 | 6c 20 70 72 69 6e 74 66 |( "norma|l printf|
|00000ff0| 20 73 74 75 66 66 2e 2e | 2e 25 64 2c 25 73 2c 65 | stuff..|.%d,%s,e|
|00001000| 74 63 5c 6e 22 2c 20 31 | 2c 20 22 74 77 6f 22 20 |tc\n", 1|, "two" |
|00001010| 29 3b 0a 20 2a 0a 20 2a | 20 4f 70 74 69 6f 6e 61 |);. *. *| Optiona|
|00001020| 6c 6c 79 2c 20 74 68 65 | 20 6d 61 63 72 6f 20 44 |lly, the| macro D|
|00001030| 42 47 4c 4f 47 5f 54 49 | 4d 45 46 4d 54 20 63 61 |BGLOG_TI|MEFMT ca|
|00001040| 6e 20 62 65 20 72 65 64 | 65 66 69 6e 65 64 20 62 |n be red|efined b|
|00001050| 65 66 6f 72 65 20 6f 72 | 0a 20 2a 20 61 66 74 65 |efore or|. * afte|
|00001060| 72 20 69 6e 63 6c 75 64 | 69 6e 67 20 74 68 65 20 |r includ|ing the |
|00001070| 68 65 61 64 65 72 20 66 | 69 6c 65 2c 20 64 62 67 |header f|ile, dbg|
|00001080| 75 74 69 6c 2e 68 2c 20 | 74 6f 20 61 20 76 61 6c |util.h, |to a val|
|00001090| 69 64 20 73 74 72 66 74 | 69 6d 65 20 66 6d 74 0a |id strft|ime fmt.|
|000010a0| 20 2a 20 73 74 72 69 6e | 67 20 75 73 69 6e 67 20 | * strin|g using |
|000010b0| 73 74 72 66 74 69 6d 65 | 20 64 69 72 65 63 74 69 |strftime| directi|
|000010c0| 76 65 73 2e 20 20 46 6f | 72 20 65 78 61 6d 70 6c |ves. Fo|r exampl|
|000010d0| 65 2c 20 54 6f 20 70 75 | 74 20 74 68 65 20 64 61 |e, To pu|t the da|
|000010e0| 79 20 6f 66 0a 20 2a 20 | 74 68 65 20 77 65 65 6b |y of. * |the week|
|000010f0| 2c 20 74 68 65 20 68 6f | 75 72 2c 20 6d 69 6e 75 |, the ho|ur, minu|
|00001100| 74 65 2c 20 61 6e 64 20 | 73 65 63 6f 6e 64 20 69 |te, and |second i|
|00001110| 6e 20 74 68 65 20 6f 75 | 74 70 75 74 2e 2e 2e 0a |n the ou|tput....|
|00001120| 20 2a 0a 20 2a 20 23 69 | 66 64 65 66 20 44 42 47 | *. * #i|fdef DBG|
|00001130| 4c 4f 47 5f 54 49 4d 45 | 46 4d 54 0a 20 2a 20 23 |LOG_TIME|FMT. * #|
|00001140| 75 6e 64 65 66 20 44 42 | 47 4c 4f 47 5f 54 49 4d |undef DB|GLOG_TIM|
|00001150| 45 46 4d 54 0a 20 2a 20 | 23 65 6e 64 69 66 0a 20 |EFMT. * |#endif. |
|00001160| 2a 20 23 64 65 66 69 6e | 65 20 44 42 47 4c 4f 47 |* #defin|e DBGLOG|
|00001170| 5f 54 49 4d 45 46 4d 54 | 20 22 25 41 2c 20 25 48 |_TIMEFMT| "%A, %H|
|00001180| 3a 25 4d 3a 25 53 22 0a | 20 2a 0a 20 2a 20 54 6f |:%M:%S".| *. * To|
|00001190| 20 70 75 74 20 67 65 74 | 20 72 69 64 20 6f 66 20 | put get| rid of |
|000011a0| 74 68 65 20 74 69 6d 65 | 73 74 61 6d 70 20 65 6e |the time|stamp en|
|000011b0| 74 69 72 65 6c 79 2e 2e | 2e 0a 20 2a 0a 20 2a 20 |tirely..|.. *. * |
|000011c0| 23 69 66 64 65 66 20 44 | 42 47 4c 4f 47 5f 54 49 |#ifdef D|BGLOG_TI|
|000011d0| 4d 45 46 4d 54 0a 20 2a | 20 23 75 6e 64 65 66 20 |MEFMT. *| #undef |
|000011e0| 44 42 47 4c 4f 47 5f 54 | 49 4d 45 46 4d 54 0a 20 |DBGLOG_T|IMEFMT. |
|000011f0| 2a 20 23 65 6e 64 69 66 | 0a 20 2a 20 23 64 65 66 |* #endif|. * #def|
|00001200| 69 6e 65 20 44 42 47 4c | 4f 47 5f 54 49 4d 45 46 |ine DBGL|OG_TIMEF|
|00001210| 4d 54 20 22 22 0a 20 2a | 0a 20 2a 20 53 65 74 20 |MT "". *|. * Set |
|00001220| 74 68 65 20 65 78 74 65 | 72 6e 61 6c 20 62 6f 6f |the exte|rnal boo|
|00001230| 6c 65 61 6e 2c 20 67 62 | 44 62 67 4c 6f 67 46 6c |lean, gb|DbgLogFl|
|00001240| 61 67 2c 20 74 72 75 65 | 20 6f 72 20 66 61 6c 73 |ag, true| or fals|
|00001250| 65 20 74 6f 20 74 75 72 | 6e 20 6f 6e 0a 20 2a 20 |e to tur|n on. * |
|00001260| 6f 72 20 74 75 72 6e 20 | 6f 66 66 20 64 65 62 75 |or turn |off debu|
|00001270| 67 67 69 6e 67 20 77 69 | 74 68 6f 75 74 20 72 65 |gging wi|thout re|
|00001280| 63 6f 6d 70 69 6c 69 6e | 67 2e 0a 20 2a 0a 20 2a |compilin|g.. *. *|
|00001290| 20 53 65 65 20 64 62 67 | 75 74 69 6c 2e 68 20 66 | See dbg|util.h f|
|000012a0| 6f 72 20 74 68 65 20 64 | 65 66 61 75 6c 74 20 64 |or the d|efault d|
|000012b0| 65 66 69 6e 69 74 69 6f | 6e 20 6f 66 20 44 42 47 |efinitio|n of DBG|
|000012c0| 4c 4f 47 5f 54 49 4d 45 | 46 4d 54 2e 0a 20 2a 2f |LOG_TIME|FMT.. */|
|000012d0| 0a 0a 76 6f 69 64 0a 5f | 44 62 67 4c 6f 67 53 65 |..void._|DbgLogSe|
|000012e0| 74 28 75 6e 73 69 67 6e | 65 64 20 63 68 61 72 20 |t(unsign|ed char |
|000012f0| 62 4c 6f 67 53 74 75 66 | 66 29 0a 7b 0a 20 20 20 |bLogStuf|f).{. |
|00001300| 20 67 62 44 62 67 4c 6f | 67 46 6c 61 67 20 3d 20 | gbDbgLo|gFlag = |
|00001310| 62 4c 6f 67 53 74 75 66 | 66 3b 0a 7d 0a 0a 2f 2a |bLogStuf|f;.}../*|
|00001320| 0a 20 2a 20 54 68 65 73 | 65 20 74 77 6f 20 72 6f |. * Thes|e two ro|
|00001330| 75 74 69 6e 65 73 20 61 | 72 65 20 6e 6f 72 6d 61 |utines a|re norma|
|00001340| 6c 20 6e 65 76 65 72 20 | 63 61 6c 6c 65 64 20 64 |l never |called d|
|00001350| 69 72 65 63 74 6c 79 2c | 20 6f 6e 6c 79 20 62 79 |irectly,| only by|
|00001360| 20 74 68 65 0a 20 2a 20 | 6d 61 63 72 6f 20 44 62 | the. * |macro Db|
|00001370| 67 4c 6f 67 20 74 68 61 | 74 20 69 73 20 64 65 66 |gLog tha|t is def|
|00001380| 69 6e 65 64 20 74 6f 20 | 62 65 20 73 6f 6d 65 74 |ined to |be somet|
|00001390| 68 69 6e 67 20 6c 69 6b | 65 2e 2e 2e 0a 20 2a 0a |hing lik|e.... *.|
|000013a0| 20 2a 20 20 20 23 64 65 | 66 69 6e 65 20 44 62 67 | * #de|fine Dbg|
|000013b0| 4c 6f 67 20 5f 44 62 67 | 4c 6f 67 31 28 5f 5f 46 |Log _Dbg|Log1(__F|
|000013c0| 49 4c 45 5f 5f 2c 20 5f | 5f 4c 49 4e 45 5f 5f 2c |ILE__, _|_LINE__,|
|000013d0| 20 44 42 47 4c 4f 47 5f | 54 49 4d 45 46 4d 54 29 | DBGLOG_|TIMEFMT)|
|000013e0| 2c 20 5f 44 62 67 4c 6f | 67 32 0a 20 2a 2f 0a 0a |, _DbgLo|g2. */..|
|000013f0| 76 6f 69 64 0a 5f 44 62 | 67 4c 6f 67 31 28 0a 20 |void._Db|gLog1(. |
|00001400| 20 20 20 20 20 20 20 20 | 20 20 20 63 68 61 72 20 | | char |
|00001410| 2a 70 73 7a 46 69 6c 65 | 2c 0a 20 20 20 20 20 20 |*pszFile|,. |
|00001420| 20 20 20 20 20 20 69 6e | 74 20 6e 4c 69 6e 65 2c | in|t nLine,|
|00001430| 0a 20 20 20 20 20 20 20 | 20 20 20 20 20 63 68 61 |. | cha|
|00001440| 72 20 2a 70 73 7a 54 69 | 6d 65 46 6d 74 29 0a 7b |r *pszTi|meFmt).{|
|00001450| 0a 20 20 20 20 63 68 61 | 72 20 20 20 20 20 20 20 |. cha|r |
|00001460| 20 20 20 20 2a 70 73 7a | 4f 6e 6c 79 46 69 6c 65 | *psz|OnlyFile|
|00001470| 6e 61 6d 65 3b 0a 20 20 | 20 20 63 68 61 72 20 20 |name;. | char |
|00001480| 20 20 20 20 20 20 20 20 | 20 20 73 7a 54 69 6d 65 | | szTime|
|00001490| 5b 36 34 5d 3b 0a 20 20 | 20 20 69 6e 74 20 20 20 |[64];. | int |
|000014a0| 20 20 20 20 20 20 20 20 | 20 20 6e 54 69 6d 65 4c | | nTimeL|
|000014b0| 65 6e 3b 0a 0a 20 20 20 | 20 69 66 20 28 21 67 62 |en;.. | if (!gb|
|000014c0| 44 62 67 4c 6f 67 46 6c | 61 67 29 0a 20 20 20 20 |DbgLogFl|ag). |
|000014d0| 20 20 20 20 72 65 74 75 | 72 6e 3b 0a 0a 20 20 20 | retu|rn;.. |
|000014e0| 20 6e 54 69 6d 65 4c 65 | 6e 20 3d 20 30 3b 0a 0a | nTimeLe|n = 0;..|
|000014f0| 20 20 20 20 69 66 20 28 | 2a 70 73 7a 54 69 6d 65 | if (|*pszTime|
|00001500| 46 6d 74 20 21 3d 20 27 | 5c 30 27 29 20 7b 0a 20 |Fmt != '|\0') {. |
|00001510| 20 20 20 20 20 20 20 74 | 69 6d 65 5f 74 20 20 20 | t|ime_t |
|00001520| 20 20 20 20 20 20 20 74 | 70 20 3d 20 74 69 6d 65 | t|p = time|
|00001530| 28 4e 55 4c 4c 29 3b 0a | 20 20 20 20 20 20 20 20 |(NULL);.| |
|00001540| 6e 54 69 6d 65 4c 65 6e | 20 3d 20 73 74 72 66 74 |nTimeLen| = strft|
|00001550| 69 6d 65 28 73 7a 54 69 | 6d 65 2c 20 73 69 7a 65 |ime(szTi|me, size|
|00001560| 6f 66 20 73 7a 54 69 6d | 65 20 2d 20 31 2c 20 70 |of szTim|e - 1, p|
|00001570| 73 7a 54 69 6d 65 46 6d | 74 2c 0a 20 20 20 20 20 |szTimeFm|t,. |
|00001580| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001590| 20 20 20 20 20 20 20 6c | 6f 63 61 6c 74 69 6d 65 | l|ocaltime|
|000015a0| 28 26 74 70 29 29 3b 0a | 20 20 20 20 7d 0a 20 20 |(&tp));.| }. |
|000015b0| 20 20 28 76 6f 69 64 29 | 20 66 70 72 69 6e 74 66 | (void)| fprintf|
|000015c0| 28 73 74 64 65 72 72 2c | 20 22 5b 25 2d 2e 2a 73 |(stderr,| "[%-.*s|
|000015d0| 25 73 25 73 2c 25 64 5d | 20 22 2c 0a 20 20 20 20 |%s%s,%d]| ",. |
|000015e0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 6e | | n|
|000015f0| 54 69 6d 65 4c 65 6e 2c | 20 73 7a 54 69 6d 65 2c |TimeLen,| szTime,|
|00001600| 0a 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |. | |
|00001610| 20 20 20 20 6e 54 69 6d | 65 4c 65 6e 20 3f 20 22 | nTim|eLen ? "|
|00001620| 20 22 20 3a 20 22 22 2c | 20 20 20 20 20 2f 2a 20 | " : "",| /* |
|00001630| 73 70 61 63 65 20 69 66 | 20 74 69 6d 65 20 64 69 |space if| time di|
|00001640| 73 70 6c 61 79 65 64 20 | 2a 2f 0a 20 20 20 20 20 |splayed |*/. |
|00001650| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 28 70 | | (p|
|00001660| 73 7a 4f 6e 6c 79 46 69 | 6c 65 6e 61 6d 65 20 3d |szOnlyFi|lename =|
|00001670| 20 73 74 72 72 63 68 72 | 28 70 73 7a 46 69 6c 65 | strrchr|(pszFile|
|00001680| 2c 20 27 2f 27 29 29 20 | 3f 0a 20 20 20 20 20 20 |, '/')) |?. |
|00001690| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 28 63 68 | | (ch|
|000016a0| 61 72 20 2a 29 20 28 70 | 73 7a 4f 6e 6c 79 46 69 |ar *) (p|szOnlyFi|
|000016b0| 6c 65 6e 61 6d 65 20 2b | 20 31 29 20 3a 20 70 73 |lename +| 1) : ps|
|000016c0| 7a 46 69 6c 65 2c 0a 20 | 20 20 20 20 20 20 20 20 |zFile,. | |
|000016d0| 20 20 20 20 20 20 20 20 | 20 20 6e 4c 69 6e 65 29 | | nLine)|
|000016e0| 3b 0a 7d 0a 0a 76 6f 69 | 64 0a 5f 44 62 67 4c 6f |;.}..voi|d._DbgLo|
|000016f0| 67 32 28 63 68 61 72 20 | 2a 70 73 7a 46 6d 74 2c |g2(char |*pszFmt,|
|00001700| 2e 2e 2e 29 0a 7b 0a 20 | 20 20 20 76 61 5f 6c 69 |...).{. | va_li|
|00001710| 73 74 20 20 20 20 20 20 | 20 20 20 61 70 3b 0a 0a |st | ap;..|
|00001720| 20 20 20 20 69 66 20 28 | 21 67 62 44 62 67 4c 6f | if (|!gbDbgLo|
|00001730| 67 46 6c 61 67 29 0a 20 | 20 20 20 20 20 20 20 72 |gFlag). | r|
|00001740| 65 74 75 72 6e 3b 0a 0a | 20 20 20 20 76 61 5f 73 |eturn;..| va_s|
|00001750| 74 61 72 74 28 61 70 2c | 20 70 73 7a 46 6d 74 29 |tart(ap,| pszFmt)|
|00001760| 3b 0a 20 20 20 20 28 76 | 6f 69 64 29 20 76 66 70 |;. (v|oid) vfp|
|00001770| 72 69 6e 74 66 28 73 74 | 64 65 72 72 2c 20 70 73 |rintf(st|derr, ps|
|00001780| 7a 46 6d 74 2c 20 61 70 | 29 3b 0a 20 20 20 20 76 |zFmt, ap|);. v|
|00001790| 61 5f 65 6e 64 28 61 70 | 29 3b 0a 20 20 20 20 66 |a_end(ap|);. f|
|000017a0| 66 6c 75 73 68 28 73 74 | 64 65 72 72 29 3b 0a 7d |flush(st|derr);.}|
|000017b0| 0a 0a 54 68 65 72 65 20 | 61 72 65 20 61 20 63 6f |..There |are a co|
|000017c0| 75 70 6c 65 20 6f 66 20 | 77 61 79 73 20 74 6f 20 |uple of |ways to |
|000017d0| 61 63 68 69 65 76 65 20 | 61 6c 6d 6f 73 74 20 77 |achieve |almost w|
|000017e0| 68 61 74 20 79 6f 75 20 | 77 61 6e 74 20 2d 0a 74 |hat you |want -.t|
|000017f0| 68 65 20 66 69 72 73 74 | 20 6f 6e 65 20 69 73 20 |he first| one is |
|00001800| 61 72 67 75 61 62 6c 79 | 20 74 6f 6f 20 63 6c 65 |arguably| too cle|
|00001810| 76 65 72 20 66 6f 72 20 | 69 74 27 73 20 6f 77 6e |ver for |it's own|
|00001820| 20 67 6f 6f 64 20 2d 20 | 79 6f 75 0a 77 72 69 74 | good - |you.writ|
|00001830| 65 20 61 20 66 75 6e 63 | 74 69 6f 6e 20 74 6f 20 |e a func|tion to |
|00001840| 68 61 6e 64 6c 65 20 74 | 68 65 20 5f 5f 46 49 4c |handle t|he __FIL|
|00001850| 45 5f 5f 20 61 6e 64 20 | 5f 5f 4c 49 4e 45 5f 5f |E__ and |__LINE__|
|00001860| 20 61 72 67 75 6d 65 6e | 74 73 0a 61 6e 64 20 69 | argumen|ts.and i|
|00001870| 74 20 72 65 74 75 72 6e | 73 20 61 20 70 6f 69 6e |t return|s a poin|
|00001880| 74 65 72 20 74 6f 20 61 | 20 66 75 6e 63 74 69 6f |ter to a| functio|
|00001890| 6e 20 77 68 69 63 68 20 | 68 61 6e 64 6c 65 73 20 |n which |handles |
|000018a0| 74 68 65 20 72 65 73 74 | 0a 6f 66 20 74 68 65 20 |the rest|.of the |
|000018b0| 61 72 67 75 6d 65 6e 74 | 73 2e 20 49 66 20 79 6f |argument|s. If yo|
|000018c0| 75 20 64 6f 6e 27 74 20 | 77 61 6e 74 20 64 65 62 |u don't |want deb|
|000018d0| 75 67 67 69 6e 67 20 6f | 75 74 70 75 74 20 79 6f |ugging o|utput yo|
|000018e0| 75 20 6a 75 73 74 0a 63 | 61 73 74 20 74 68 65 20 |u just.c|ast the |
|000018f0| 6c 69 73 74 20 6f 66 20 | 65 78 70 72 65 73 73 69 |list of |expressi|
|00001900| 6f 6e 73 20 69 6e 20 70 | 61 72 65 6e 74 68 65 73 |ons in p|arenthes|
|00001910| 65 73 20 74 6f 20 28 76 | 6f 69 64 29 20 61 6e 64 |es to (v|oid) and|
|00001920| 20 61 6e 79 0a 68 61 6c | 66 20 64 65 63 65 6e 74 | any.hal|f decent|
|00001930| 20 63 6f 6d 70 69 6c 65 | 72 73 20 77 6f 6e 27 74 | compile|rs won't|
|00001940| 20 67 65 6e 65 72 61 74 | 65 20 61 6e 79 20 63 6f | generat|e any co|
|00001950| 64 65 2e 0a 0a 54 68 65 | 20 73 65 63 6f 6e 64 20 |de...The| second |
|00001960| 76 65 72 73 69 6f 6e 20 | 69 73 20 73 69 6d 70 6c |version |is simpl|
|00001970| 65 72 20 69 6e 20 74 68 | 61 74 20 69 74 20 64 6f |er in th|at it do|
|00001980| 65 73 6e 27 74 20 75 73 | 65 20 74 68 65 20 74 72 |esn't us|e the tr|
|00001990| 69 63 6b 0a 6f 66 20 72 | 65 74 75 72 6e 69 6e 67 |ick.of r|eturning|
|000019a0| 20 61 20 66 75 6e 63 74 | 69 6f 6e 20 70 6f 69 6e | a funct|ion poin|
|000019b0| 74 65 72 20 66 72 6f 6d | 20 74 68 65 20 66 69 72 |ter from| the fir|
|000019c0| 73 74 20 66 75 6e 63 74 | 69 6f 6e 20 2d 20 69 74 |st funct|ion - it|
|000019d0| 0a 6a 75 73 74 20 75 73 | 65 73 20 74 68 65 20 63 |.just us|es the c|
|000019e0| 6f 6d 6d 61 20 6f 70 65 | 72 61 74 6f 72 20 61 6e |omma ope|rator an|
|000019f0| 64 20 69 6e 63 6c 75 64 | 65 73 20 74 68 65 20 6e |d includ|es the n|
|00001a00| 61 6d 65 20 6f 66 20 74 | 68 65 0a 73 65 63 6f 6e |ame of t|he.secon|
|00001a10| 64 20 66 75 6e 63 74 69 | 6f 6e 20 69 6e 20 74 68 |d functi|on in th|
|00001a20| 65 20 6d 61 63 72 6f 20 | 65 78 70 61 6e 73 69 6f |e macro |expansio|
|00001a30| 6e 2e 0a 0a 2f 2a 0a 20 | 2a 20 65 78 61 6d 70 6c |n.../*. |* exampl|
|00001a40| 65 20 31 0a 20 2a 2f 0a | 23 69 6e 63 6c 75 64 65 |e 1. */.|#include|
|00001a50| 20 20 20 20 20 20 20 20 | 3c 73 74 64 69 6f 2e 68 | |<stdio.h|
|00001a60| 3e 0a 23 69 6e 63 6c 75 | 64 65 20 20 20 20 20 20 |>.#inclu|de |
|00001a70| 20 20 3c 73 74 64 61 72 | 67 2e 68 3e 0a 0a 23 69 | <stdar|g.h>..#i|
|00001a80| 66 64 65 66 20 44 45 42 | 55 47 0a 76 6f 69 64 20 |fdef DEB|UG.void |
|00001a90| 44 65 62 75 67 4c 6f 67 | 32 28 63 6f 6e 73 74 20 |DebugLog|2(const |
|00001aa0| 63 68 61 72 20 2a 66 6d | 74 2c 20 2e 2e 2e 29 0a |char *fm|t, ...).|
|00001ab0| 7b 0a 20 20 20 20 76 61 | 5f 6c 69 73 74 20 20 20 |{. va|_list |
|00001ac0| 20 20 61 70 3b 0a 0a 20 | 20 20 20 76 61 5f 73 74 | ap;.. | va_st|
|00001ad0| 61 72 74 28 61 70 2c 20 | 66 6d 74 29 3b 0a 20 20 |art(ap, |fmt);. |
|00001ae0| 20 20 28 76 6f 69 64 29 | 20 76 66 70 72 69 6e 74 | (void)| vfprint|
|00001af0| 66 28 73 74 64 65 72 72 | 2c 20 66 6d 74 2c 20 61 |f(stderr|, fmt, a|
|00001b00| 70 29 3b 0a 20 20 20 20 | 76 61 5f 65 6e 64 28 61 |p);. |va_end(a|
|00001b10| 70 29 3b 0a 7d 0a 0a 76 | 6f 69 64 20 28 2a 44 65 |p);.}..v|oid (*De|
|00001b20| 62 75 67 4c 6f 67 28 63 | 6f 6e 73 74 20 63 68 61 |bugLog(c|onst cha|
|00001b30| 72 20 2a 66 69 6c 65 2c | 20 69 6e 74 20 6c 69 6e |r *file,| int lin|
|00001b40| 65 29 29 28 63 6f 6e 73 | 74 20 63 68 61 72 20 2a |e))(cons|t char *|
|00001b50| 66 6d 74 2c 20 2e 2e 2e | 29 0a 7b 0a 20 20 20 20 |fmt, ...|).{. |
|00001b60| 28 76 6f 69 64 29 66 70 | 72 69 6e 74 66 28 73 74 |(void)fp|rintf(st|
|00001b70| 64 65 72 72 2c 20 22 44 | 45 42 55 47 3a 20 46 69 |derr, "D|EBUG: Fi|
|00001b80| 6c 65 20 25 73 2c 20 4c | 69 6e 65 20 25 64 3a 20 |le %s, L|ine %d: |
|00001b90| 22 2c 20 66 69 6c 65 2c | 20 6c 69 6e 65 29 3b 0a |", file,| line);.|
|00001ba0| 20 20 20 20 72 65 74 75 | 72 6e 20 44 65 62 75 67 | retu|rn Debug|
|00001bb0| 4c 6f 67 32 3b 0a 7d 0a | 0a 23 64 65 66 69 6e 65 |Log2;.}.|.#define|
|00001bc0| 20 44 62 67 4c 6f 67 20 | 20 44 65 62 75 67 4c 6f | DbgLog | DebugLo|
|00001bd0| 67 28 5f 5f 46 49 4c 45 | 5f 5f 2c 20 5f 5f 4c 49 |g(__FILE|__, __LI|
|00001be0| 4e 45 5f 5f 29 0a 23 65 | 6c 73 65 0a 23 64 65 66 |NE__).#e|lse.#def|
|00001bf0| 69 6e 65 20 44 62 67 4c | 6f 67 20 20 28 76 6f 69 |ine DbgL|og (voi|
|00001c00| 64 29 0a 23 65 6e 64 69 | 66 0a 0a 6d 61 69 6e 28 |d).#endi|f..main(|
|00001c10| 69 6e 74 20 61 72 67 63 | 2c 20 63 68 61 72 20 2a |int argc|, char *|
|00001c20| 61 72 67 76 5b 5d 29 0a | 7b 0a 20 20 20 20 44 62 |argv[]).|{. Db|
|00001c30| 67 4c 6f 67 28 22 61 72 | 67 63 20 3d 20 25 64 2c |gLog("ar|gc = %d,|
|00001c40| 20 61 72 67 76 5b 30 5d | 20 3d 20 25 73 5c 6e 22 | argv[0]| = %s\n"|
|00001c50| 2c 20 61 72 67 63 2c 20 | 61 72 67 76 5b 30 5d 29 |, argc, |argv[0])|
|00001c60| 3b 0a 0a 20 20 20 20 72 | 65 74 75 72 6e 20 30 3b |;.. r|eturn 0;|
|00001c70| 0a 7d 0a 0a 2f 2a 0a 20 | 2a 20 65 78 61 6d 70 6c |.}../*. |* exampl|
|00001c80| 65 20 32 0a 20 2a 2f 0a | 23 69 6e 63 6c 75 64 65 |e 2. */.|#include|
|00001c90| 20 20 20 20 20 20 20 20 | 3c 73 74 64 69 6f 2e 68 | |<stdio.h|
|00001ca0| 3e 0a 23 69 6e 63 6c 75 | 64 65 20 20 20 20 20 20 |>.#inclu|de |
|00001cb0| 20 20 3c 73 74 64 61 72 | 67 2e 68 3e 0a 0a 23 69 | <stdar|g.h>..#i|
|00001cc0| 66 64 65 66 20 44 45 42 | 55 47 0a 76 6f 69 64 20 |fdef DEB|UG.void |
|00001cd0| 44 65 62 75 67 4c 6f 67 | 32 28 63 6f 6e 73 74 20 |DebugLog|2(const |
|00001ce0| 63 68 61 72 20 2a 66 6d | 74 2c 20 2e 2e 2e 29 0a |char *fm|t, ...).|
|00001cf0| 7b 0a 20 20 20 20 76 61 | 5f 6c 69 73 74 20 20 20 |{. va|_list |
|00001d00| 20 20 61 70 3b 0a 0a 20 | 20 20 20 76 61 5f 73 74 | ap;.. | va_st|
|00001d10| 61 72 74 28 61 70 2c 20 | 66 6d 74 29 3b 0a 20 20 |art(ap, |fmt);. |
|00001d20| 20 20 28 76 6f 69 64 29 | 20 76 66 70 72 69 6e 74 | (void)| vfprint|
|00001d30| 66 28 73 74 64 65 72 72 | 2c 20 66 6d 74 2c 20 61 |f(stderr|, fmt, a|
|00001d40| 70 29 3b 0a 20 20 20 20 | 76 61 5f 65 6e 64 28 61 |p);. |va_end(a|
|00001d50| 70 29 3b 0a 7d 0a 0a 76 | 6f 69 64 20 44 65 62 75 |p);.}..v|oid Debu|
|00001d60| 67 4c 6f 67 31 28 63 6f | 6e 73 74 20 63 68 61 72 |gLog1(co|nst char|
|00001d70| 20 2a 66 69 6c 65 2c 20 | 69 6e 74 20 6c 69 6e 65 | *file, |int line|
|00001d80| 29 0a 7b 0a 20 20 20 20 | 28 76 6f 69 64 29 66 70 |).{. |(void)fp|
|00001d90| 72 69 6e 74 66 28 73 74 | 64 65 72 72 2c 20 22 44 |rintf(st|derr, "D|
|00001da0| 45 42 55 47 3a 20 46 69 | 6c 65 20 25 73 2c 20 4c |EBUG: Fi|le %s, L|
|00001db0| 69 6e 65 20 25 64 3a 20 | 22 2c 20 66 69 6c 65 2c |ine %d: |", file,|
|00001dc0| 20 6c 69 6e 65 29 3b 0a | 7d 0a 0a 23 64 65 66 69 | line);.|}..#defi|
|00001dd0| 6e 65 20 44 62 67 4c 6f | 67 20 20 44 65 62 75 67 |ne DbgLo|g Debug|
|00001de0| 4c 6f 67 31 28 5f 5f 46 | 49 4c 45 5f 5f 2c 20 5f |Log1(__F|ILE__, _|
|00001df0| 5f 4c 49 4e 45 5f 5f 29 | 2c 20 44 65 62 75 67 4c |_LINE__)|, DebugL|
|00001e00| 6f 67 32 0a 23 65 6c 73 | 65 0a 23 64 65 66 69 6e |og2.#els|e.#defin|
|00001e10| 65 20 44 62 67 4c 6f 67 | 20 20 28 76 6f 69 64 29 |e DbgLog| (void)|
|00001e20| 0a 23 65 6e 64 69 66 0a | 0a 6d 61 69 6e 28 69 6e |.#endif.|.main(in|
|00001e30| 74 20 61 72 67 63 2c 20 | 63 68 61 72 20 2a 61 72 |t argc, |char *ar|
|00001e40| 67 76 5b 5d 29 0a 7b 0a | 20 20 20 20 44 62 67 4c |gv[]).{.| DbgL|
|00001e50| 6f 67 28 22 61 72 67 63 | 20 3d 20 25 64 2c 20 61 |og("argc| = %d, a|
|00001e60| 72 67 76 5b 30 5d 20 3d | 20 25 73 5c 6e 22 2c 20 |rgv[0] =| %s\n", |
|00001e70| 61 72 67 63 2c 20 61 72 | 67 76 5b 30 5d 29 3b 0a |argc, ar|gv[0]);.|
|00001e80| 0a 20 20 20 20 72 65 74 | 75 72 6e 20 30 3b 0a 7d |. ret|urn 0;.}|
|00001e90| 0a 0a 0a 2d 2d 0a 47 6c | 65 6e 6e 20 43 61 72 72 |...--.Gl|enn Carr|
|00001ea0| 2c 20 67 63 61 72 72 40 | 6c 67 63 2e 63 6f 6d 0a |, gcarr@|lgc.com.|
|00001eb0| 4c 61 6e 64 6d 61 72 6b | 20 47 72 61 70 68 69 63 |Landmark| Graphic|
|00001ec0| 73 0a 0a 22 50 6f 6c 69 | 74 69 63 73 20 6f 66 74 |s.."Poli|tics oft|
|00001ed0| 65 6e 20 69 73 20 61 20 | 6d 61 74 74 65 72 20 6f |en is a |matter o|
|00001ee0| 66 20 74 65 6d 70 65 72 | 61 6d 65 6e 74 73 20 6d |f temper|aments m|
|00001ef0| 61 73 71 75 65 72 61 64 | 69 6e 67 20 61 73 20 63 |asquerad|ing as c|
|00001f00| 72 65 65 64 73 2e 20 20 | 48 65 6e 63 65 20 42 69 |reeds. |Hence Bi|
|00001f10| 6c 6c 20 43 6c 69 6e 74 | 6f 6e 27 73 20 63 72 65 |ll Clint|on's cre|
|00001f20| 65 64 2c 20 77 68 69 63 | 68 0a 69 73 20 74 68 65 |ed, whic|h.is the|
|00001f30| 20 69 6e 74 65 6c 6c 65 | 63 74 75 61 6c 20 65 71 | intelle|ctual eq|
|00001f40| 75 69 76 61 6c 65 6e 74 | 20 6f 66 20 74 68 65 20 |uivalent| of the |
|00001f50| 69 6e 73 69 64 65 20 6f | 66 20 61 20 6a 65 6c 6c |inside o|f a jell|
|00001f60| 79 20 64 6f 75 67 68 6e | 75 74 2c 20 73 75 67 61 |y doughn|ut, suga|
|00001f70| 72 79 20 61 6e 64 20 73 | 68 61 70 65 6c 65 73 73 |ry and s|hapeless|
|00001f80| 2e 22 0a 20 20 20 20 20 | 2d 2d 47 65 6f 72 67 65 |.". |--George|
|00001f90| 20 57 69 6c 6c 2c 20 54 | 68 65 20 57 61 73 68 69 | Will, T|he Washi|
|00001fa0| 6e 67 74 6f 6e 20 50 6f | 73 74 2c 20 32 2f 31 34 |ngton Po|st, 2/14|
|00001fb0| 2f 39 36 0a | |/96. | |
+--------+-------------------------+-------------------------+--------+--------+